const express = require('express');
const router = new express.Router();

/**
 * @param {Object} options
 * @param {} options.code PI编号
 * @param {} options.claimSettlementBill 结算单号
 * @param {} options.dealerId 服务站Id
 * @param {} options.brandId 品牌Id
 * @param {} options.status 状态  1-新建  2-发票确认  3-审核中  4-驳回  5-已审核  -1-作废
 * @param {} options.beginSubmitTime 开票时间-开始时间
 * @param {} options.endSubmitTime 开票时间-结束时间
 * @param {} options.pageSize 每页数据量
 * @param {} options.pageIndex 指定页
 * @param {} options.sortField 排序字段
 * @param {} options.isDesc 倒序排列
 * @throws {Error}
 * @return {Promise}
 */
router.get('/forCurrentUser', async(req, res, next) => {
    const options = {
        code: req.query.code,
        claimSettlementBill: req.query.claimSettlementBill,
        dealerId: req.query.dealerId,
        brandId: req.query.brandId,
        status: req.query.status,
        beginSubmitTime: req.query.beginSubmitTime,
        endSubmitTime: req.query.endSubmitTime,
        pageSize: req.query.pageSize,
        pageIndex: req.query.pageIndex,
        sortField: req.query.sortField,
        isDesc: req.query.isDesc
    };
    const data = {
        message: 'message',
        payload: {
            content: [
                {
                    id: 'id133',
                    code: 'code134',
                    claimSettlementBill: 'claimSettlementBill',
                    brandCode: 'brandCode135',
                    dealerCode: 'dealerCode136',
                    sparePartsCost: 1,
                    administrationFee: 1,
                    labourCost: 1,
                    accessoryMaterial: 1,
                    amount: 1,
                    currency: 1,
                    status: 1,
                    paymentStatus: 1,
                    sapVoucherNo: 'sapVoucherNo',
                    submitTime: '2019-09-16T09:02:32Z',
                    attachments: [
                        {
                            fileId: 'fileId137',
                            fileName: 'fileName138'
                        }
                    ],
                    rowVersion: 'rowVersion',
                    options: [
                        'confirm', 'abandon', 'approve', 'export'
                    ]
                },
                {
                    id: 'id139',
                    code: 'code140',
                    claimSettlementBill: 'claimSettlementBill',
                    brandCode: 'brandCode141',
                    dealerCode: 'dealerCode142',
                    sparePartsCost: 1,
                    administrationFee: 1,
                    labourCost: 1,
                    accessoryMaterial: 1,
                    amount: 1,
                    currency: 1,
                    status: 1,
                    paymentStatus: 1,
                    sapVoucherNo: 'sapVoucherNo',
                    submitTime: '2019-09-16T09:02:32Z',
                    attachments: [
                        {
                            fileId: 'fileId137',
                            fileName: 'fileName138'
                        }
                    ],
                    rowVersion: 'rowVersion',
                    options: [
                        'confirm', 'abandon', 'approve', 'export'
                    ]
                }
            ],
            pageIndex: null,
            pageSize: null,
            sort: null,
            totalElements: 50,
            totalPages: null
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.get('/:id', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message',
        payload: {
            id: 'id143',
            code: 'code144',
            claimSettlementBill: 'claimSettlementBill',
            brandCode: 'brandCode145',
            dealerCode: 'dealerCode146',
            sparePartsCost: 1,
            administrationFee: 1,
            labourCost: 1,
            accessoryMaterial: 1,
            amount: 1,
            currency: 1,
            status: 1,
            paymentStatus: 1,
            sapVoucherNo: 'sapVoucherNo',
            submitTime: '2019-09-16T09:02:32Z',
            attachments: [
                {
                    fileId: 'fileId147',
                    fileName: 'fileName148'
                },
                {
                    fileId: 'fileId149',
                    fileName: 'fileName150'
                }
            ],
            rowVersion: 'rowVersion',
            options: [
                'confirm', 'abandon', 'approve', 'export'
            ],
            approveResults: [
                {
                    id: 'id151',
                    approverName: 'approverName152',
                    approveTime: '2019-09-16T09:02:32Z',
                    approveComment: 'approveComment',
                    approveResult: 'approveResult'
                },
                {
                    id: 'id153',
                    approverName: 'approverName154',
                    approveTime: '2019-09-16T09:02:32Z',
                    approveComment: 'approveComment',
                    approveResult: 'approveResult'
                }
            ]
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/abandon', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/confirm', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/pass', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/reject', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.get('/:id/export', (req, res) => {
    res.json({
        message: '导出成功'
    });
});
module.exports = router;
